<template>
  <div class="fh">
    {{user|json}}
    <login-view v-if="!loginedUser"></login-view>
    <div class="fh wrapper" v-else>
      <side-menu class="header">
        <side-menu-item title="控制台" icon=""></side-menu-item>
      </side-menu>
      <router-view></router-view>
    </div>
  </div>
</template>

<script>
  import LoginView from '../components/LoginView'
  import {setUser} from '../vuex/actions'
  import {getLoginedUser} from '../apis/common'
  export default {
    components: {LoginView},
    vuex: {
      actions: {setUser},
      getters: {
        loginedUser: (state) => state.user
      }
    },
    ready () {
      getLoginedUser().then(({data: {success, user}}) => {
        if (success) this.setUser(user)
      })
    }
  }
</script>

<style lang="stylus">
  .wrapper
    relative: 0 0
    padding-left: 260px
    .header
      absolute: top 0 right 0 bottom 0 left 0
</style>